<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="|#{customer.systemTitle}-用户权限-组织机构维度|">图灵谷</title>
<div th:replace="fragments/head_admin">head</div>
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<div th:replace="fragments/nav_admin">导航栏</div>
		<div th:replace="fragments/menu_admin::menu(parent=site,child=guestbookType)">菜单栏</div>
		<div class="layui-body">
			<div class="layui-main">
				<!--/***** 面包屑 *****/-->
				<div class="layui-elem-quote" style="margin-top: 10px;">
					<span class="layui-breadcrumb"> <a><cite>站点管理</cite></a> <a th:href="@{/admin/m/ext/guestbookType/list.gsp}">留言板类型</a> <a><cite>修改</cite></a>
					</span>
				</div>
				<form th:action="@{/admin/m/ext/guestbookType/edit.gsp}" th:object="${result}" class="layui-form" id="editForm" role="form" action="#" method="post">
					<fieldset class="layui-elem-field layui-field-title">
						<legend>修改留言类型</legend>
					</fieldset>
					<input th:field="*{id}" name="id" type="text" hidden="hidden" />
					<div class="layui-form-item">
						<label class="layui-form-label">类型名称：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<input type="text" name="typeName" th:field="*{typeName}" placeholder="请输入类型名称" lay-verify="typeName" required autocomplete="off" class="layui-input" autofocus="autofocus" maxlength="21">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">类型编码：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<input type="text" name="codeNum" th:field="*{codeNum}" placeholder="请输入类型编码" lay-verify="codeNum" required autocomplete="off" class="layui-input" autofocus="autofocus" maxlength="21">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">开放模式：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<select name="openType" th:field="*{openType}">
								<option value="1">关闭留言</option>
								<option value="2">开放前台会员</option>
								<option value="3">前台会员及游客</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">审核模式：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<select name="verifyType" th:field="*{verifyType}"> <
								<option value="1">不需要审核</option>
								<option value="2">游客需要审核</option>
								<option value="3">游客及前台会员</option>
								<option value="4">所有人员</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">验证码模式：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<select name="captchaType" th:field="*{captchaType}">
								<option value="1">不需要验证码</option>
								<option value="2">游客需要验证</option>
								<option value="3">游客及前台会员</option>
								<option value="4">所有人员</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">最大长度：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<input type="number" name="maxLength" th:field="*{maxLength}" min="1" value="140" max="1000" placeholder="请输入最大长度" lay-verify="maxLength" required autocomplete="off" class="layui-input" autofocus="autofocus">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label"> 排序：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<input type="number" name="sortOrder" th:field="*{sortOrder}" min="1" max="99" value="1" required autocomplete="off" class="layui-input" autofocus="autofocus">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label"> 描 述：</label>
						<div class="layui-input-block">
							<textarea type="text" name="description" th:field="*{description}" placeholder="最多输入140字" lay-verify="description" autocomplete="off" class="layui-textarea" autofocus="autofocus" maxlength="150"></textarea>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit="" lay-filter="submit1">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div th:replace="fragments/footer_admin">底部</div>
	</div>
</body>
<div th:replace="fragments/import_js_admin">引入js</div>
</html>
<script th:inline="javascript">
    /*<![CDATA[*/
     var result = false;
     var id = /*[[${result.id}]]*/;
    //检查职务是否存在
    function checkTypeName(typeName){
        $.ajax({
            url:/*[[@{/admin/m/ext/guestbookType/checkTypeName.gsp}]]*/,
            type:"post",
            async : false,
            data:{"id":id,"typeName":typeName},
            dataType:"json",
            success:function(data){              
                result = data;              
            }                                   
        });
        return result;
    }
    //检查头衔是否存在
    function checkCodeNum(codeNum){
        $.ajax({
            url:/*[[@{/admin/m/ext/guestbookType/checkCodeNum.gsp}]]*/,
            type:"post",
            async : false,
            data:{"id":id,"codeNum":codeNum},
            dataType:"json",
            success:function(data){              
                result = data;          
            }                                   
        });
        return result;
    }
    var form = layui.form();
    //自定义验证规则
    form.verify({
        typeName : function(value) {
            if (value.length < 1) {
                return '类型名称不能为空哦！';
            } else if (value.length > 20) {
                return '类型名称不能太长哦，最长20个字！';
            } else if(checkTypeName(value)==false){
                return '该类型名称已经存在，请勿重复提交！';
            }
        },
        codeNum : function(value) {
            if (value.length < 1) {
                return '类型编码不能为空哦！';
            } else if (value.length > 20) {
                return '类型编码不能太长哦，最长20个字！';
            } else if(checkCodeNum(value)==false){
                return '该类型名称已经存在，请勿重复提交！';
            }
        },
        maxLength : function(value) {
            if (value.length < 1) {
                return '最大长度不能小于1！';
            } else if (value.length > 1000) {
                return '最大长度不能大于1000！';
            }
        },
        sortOrder : function(value) {
            if (value.length < 1) {
                return '排序不能小于1！';
            } else if (value.length > 99) {
                return '排序不能大于99！';
            }
        },
        description : function(value) {
            if (value.length > 140) {
                return 'meta描述不能太长哦，最长140个字！';
            }
        }
    });
    //监听提交
    form.on('submit(submit1)', function(data) {
    });
    /*]]>*/
</script>